# -*- coding: utf-8 -*-
"""
Created on Wed Apr  3 10:44:44 2024

@author: 刘翼
"""

import cv2

img = cv2.imread(r"C:\Users\Public\opencv\Figure\jianzhu.png")
#img = cv2.imread("D:/pics/lenasp.jpg")                                #读取带有椒盐噪声的图像
img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)   #转化为灰度图像
img_gaus = cv2.GaussianBlur(img_gray,(3,3),0)                   #高斯滤波

# Canny边缘检测，设置两个阈值分别为100和200
edge_output = cv2.Canny(img_gaus,100,200)
dst = cv2.bitwise_and(img, img, mask= edge_output)

cv2.imshow("Original",img)
cv2.imshow("canny",edge_output)
cv2.imshow("Color Edge", dst)
cv2.waitKey()
cv2.destroyAllWindows()

